<? include 'server_config.php'; 

if($_SESSION['user_idx'] == "")
{
	?>
	<script>
		location.href='login.php';
	</script>
	<?
	return;
}

?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>

<?

if($comment_idx=="")
{

	$sql = "
	INSERT INTO ndd_comment
	VALUES
	(
	'', '$document_idx', '$board_idx', '".$_SESSION['user_idx']."', 0, '$content', 0, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
	";

	//echo $sql;
	$result = mysql_query($sql,$connect);


	$sql = "
	UPDATE ndd_document SET comment_count = comment_count+1 WHERE document_idx = '$document_idx';
	";

	//echo $sql;
	$result = mysql_query($sql,$connect);

	?>
<script> 
//location.replace("<? echo $_POST['current_location']; ?>");
//	parent.talk_display_article(<? echo $document_idx; ?>);
</script>
	<?
}
else
{
	$sql = "
	UPDATE ndd_comment SET content = '$content'
	WHERE comment_idx = '$comment_idx' AND user_idx = '".$_SESSION['user_idx']."';
	";

//	echo $sql;
	$result = mysql_query($sql,$connect);
?>
<script> 
//location.replace("<? echo $_POST['current_location_'.$comment_idx]; ?>");
</script>
<?
}

if($board_idx==-1)
{
	//팀게시판이므로 새글 등록 알림
	//현재 사용하지 않음

	//http://sajaa.cafe24.com/ndd/board_document.php?name=team&category_idx=0&page=1&document_idx=6&action=view


	$name = "넥도닥";
	$frommail = "no-replay@nextdoordoctor.co.kr";
	$tomail = "<hotae913@gmail.com>, <amh1987@naver.com>, <sunshine.somin@gmail.com>, <seunghwonyi@gmail.com>";
	$subject = "[넥도닥] 게시판에 새 글이 등록되었습니다.";
	$memo = "게시판에 새 글이 등록되었습니다.<br><br>제목 : ".$title."<br><br><a href='http://sajaa.cafe24.com/ndd/board_document.php?name=team&category_idx=".$category_idx."&document_idx=".$document_idx."&action=view'><font color='blue'>글 보러가기</font></a> 링크를 클릭하면 해당 글 페이지로 이동합니다.<br><br>";


	/* mail()함수에서 쓰게될 변수 */

	$mh.="Return-Path: $frommail\r\n";
	$mh.="From: $name <$frommail>\r\n";
	$mh.= "Content-Type: text/html; charset=\"UTF-8\"\r\n";
	/* 줄의 끝에 붙어 있는 슬래쉬를 제거하는 함수 */

//	$memo=stripslashes($memo);


	/* 메일을 보내주는 함수 */
/*
	echo $tomail."<br>";
	echo $subject."<br>";
	echo $memo."<br>";
	echo $mh."<br>";
*/
	mail($tomail, $subject, $memo, $mh);



}


?>













